package com.neuedu.studentmanage.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neuedu.studentmanage.entity.Pager;
import com.neuedu.studentmanage.entity.Result;
import com.neuedu.studentmanage.entity.Student;
import com.neuedu.studentmanage.mapper.StudentMapper;
import com.neuedu.studentmanage.service.StudentService;

@Service
@Transactional
public class StudentServiceImpl implements StudentService {

	@Autowired
	private StudentMapper studentMapper;

	@Override
	public List<Student> findListByPager(Pager<Student> pager) {

		return studentMapper.findListByPager(pager);
	}

	@Override
	public Integer findTotalByPager(Pager<Student> pager) {

		return studentMapper.findTotalByPager(pager);
	}

	@Override
	public Result add(Student object) {
		Result result = new Result(false, "新增学生信息失败");
		boolean ret = studentMapper.add(object);
		if (ret) {
			result = new Result(true, "新增学生信息成功");
		}
		return result;
	}

	@Override
	public Result edit(Student object) {
		Result result = new Result(false, "修改学生信息失败");
		boolean ret = studentMapper.edit(object);
		if (ret) {
			result = new Result(true, "修改学生信息成功");
		}
		return result;
	}

	@Override
	public Result deleteByIds(List<Student> ids) {
		Result result = new Result(false, "删除学生信息失败");
		boolean ret = studentMapper.deleteByIds(ids);
		if (ret) {
			result = new Result(true, "删除学生信息成功");
		}
		return result;
	}

	@Override
	public List<Student> findAll() {

		return studentMapper.findAll();
	}

	@Override
	public Student login(Student student) {

		return studentMapper.login(student);
	}

	@Override
	public Student findById(Integer stuId) {

		return studentMapper.findById(stuId);
	}

}
